package nl.borchef.map_2d_game;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

public class game {
	private int mi_canvas_width;
	private int mi_canvas_height;
	private long ml_draw_time;
	private boolean mb_running = true;
	private boolean mb_surface_ready = false;
	private boolean mb_paused = false;
    private game_map_2d mo_game_map;
    private tank mo_tank;
    private Paint mo_paint_text;
	private paint_colors mo_paint_colors;
    public game(Context context){
        // Initialize paints
		mo_paint_colors = new paint_colors();
		mo_tank = new tank(mo_paint_colors, this);
		mo_game_map = new game_map_2d(mo_paint_colors);
	}
	public synchronized void draw(Canvas canvas){
		
		canvas.drawPaint( mo_paint_colors.get_back_ground_color() );
		mo_game_map.update_physics( mo_tank);
		mo_game_map.draw(canvas);
		mo_tank.draw(canvas );
		
		//drawing fps
		long time = System.currentTimeMillis();
    	long time_elapsed = time - ml_draw_time;
        int fps = (int) (1000 / time_elapsed);
        String text = String.format("fps = %d", fps);
        canvas.drawText(text, 0, text.length(), 10, 100, mo_paint_colors.get_paint_big_black_text());
        ml_draw_time = time;
	
	}
	public synchronized void touched(float x, float y){
		mo_game_map.set_target_destination(x, y);
	}
	public synchronized void update(){
	}
	public synchronized void set_paused(boolean paused){
		mb_paused = paused;
	}
	public synchronized boolean get_paused(){
		return mb_paused;
	}
	public synchronized void set_surface_ready(boolean surface_ready){
		mb_surface_ready = surface_ready;
	}
	public synchronized boolean get_surface_ready(){
		return mb_surface_ready;
	}
	public synchronized void set_running(boolean running){
		mb_running = running;
	}
	public synchronized boolean get_running(){
		return mb_running;
	}
	public synchronized void set_canvas_width(int width){
		mi_canvas_width = width;
		mo_game_map.set_canvas_width( width);
		mo_tank.set_canvas_width( width);
	}
	public synchronized void set_canvas_height(int height){
		mi_canvas_height = height;
		mo_game_map.set_canvas_height( height);
		mo_tank.set_canvas_height( height);
	}
	public void play_tank_driving_sound(boolean play){
	}
	
}
